#!/usr/bin/perl
use warnings;
use strict;
use lib 'lib';

my $foo = Foo->new;
#my $sum = $foo->addup( 1, 2, 3 );
my $sum = $foo->call_wrapped( '(+ foo bar)', { foo => 23, bar => 13 } );
print "Added up to $sum\n";
my $con = $foo->call_wrapped( 
    '(string-append foo (bar))', { foo => "Foo", bar => sub { "Bar" } }
);
print "Concatenated to $con\n";
my $two = $foo->call_wrapped(
    '(dbl ((foo)))', { foo => sub { sub { 23 } }, dbl => sub { shift( @_ ) * 2 } }
);
print "Anon Test (should be 46): $two\n";

my $out = $foo->call_wrapped(
    '(sprintf "%d(%s)" foo (bar "baz"))',
    { 'sprintf' => sub { my ( $fmt, @args ) = @_ ; sprintf $fmt, @args },
      foo => 23,
      bar => sub { ucfirst shift },
    },
);
print "Output [23(Baz)]: $out\n";







BEGIN {
package Foo;
use warnings;
use strict;

use Class::Guile-base;

guile_method addup => q(
    (lambda ls (apply + ls))
);




1;
}
